#include "vl_future.h"

using namespace VL;


/**
 * +======================================================================================================================+
 * @Author: CimZzz
 * @Date: 2022-09-16 10:39:31
 * 
 * 代码分割块，以下内容涉及: 
 * 
 * VLFutureBase
 * 
 */

/**
 * @Author: CimZzz
 * @Date: 2022-09-16 10:39:10
 * 
 * 构造方法
 */
VLFutureBase::VLFutureBase(): completed(false), interrupted(false) {

}

/**
 * @Author: CimZzz
 * @Date: 2022-09-16 10:39:15
 * 
 * 析构方法
 */
VLFutureBase::~VLFutureBase() {

}

/**
 * @Author: CimZzz
 * @Date: 2022-08-21 15:17:36
 * 
 * 中断当前 Future 任务
 */
void VLFutureBase::interrupt() {
}

/**
 * @Author: CimZzz
 * @Date: 2022-08-21 08:17:08
 * 
 * 等待结果
 */
void VLFutureBase::wait() {
	std::unique_lock<std::mutex> locker(this->mutex);
	if(this->completed || this->interrupted) {
		return;
	}
	this->cond.wait(locker);
}

/**
 * @Author: CimZzz
 * @Date: 2022-08-21 08:17:50
 * 
 * 判断 Future 是否已经完成
 * 
 * @return 如果成功返回 true
 */
bool VLFutureBase::isCompleted() {
	return this->completed;
}

/**
 * @Author: CimZzz
 * @Date: 2022-08-21 08:17:50
 * 
 * 判断 Future 是否已经中断
 * 
 * @return 如果中断返回 true
 */
bool VLFutureBase::isInterrupted() {
	return this->interrupted;
}

/**
 * @Author: CimZzz
 * @Date: 2022-08-21 16:28:12
 * 
 * 获取数据, 否则抛出异常
 */
void VLFutureBase::getOrThrow() {
	return;
}

/**
 * +======================================================================================================================+
 * @Author: CimZzz
 * @Date: 2022-08-21 15:18:15
 * 
 * 代码分割块，以下内容涉及: 
 * 
 * VLFuture
 * 
 */


/**
 * @Author: CimZzz
 * @Date: 2022-08-21 08:16:38
 * 
 * 保护构造函数
 */
VLFuture::VLFuture() {
}
